﻿import QtQuick 2.0

import "../../js/util.js" as Util

ACellRow {
    id: id_root
    property var person
    signal clickSignal

    onPersonChanged: {
        m_NameText_id.text = setText()
    }

    m_leftItem: Item {
        width: m_lineValue
        height: m_lineValue

        HeadImage {
            id: m_HeadImg_id
            width: parent.width*0.7
            height: parent.height*0.7
            anchors.centerIn: parent
            m_source: person.picname
        }
    }

    m_centerItem: Column {
        anchors.verticalCenter: parent.verticalCenter
        spacing: m_lineValue*0.15
        AText {
            id: m_NameText_id
            font.pointSize: 18
        }

        AText {
            id: m_phoneText_id
            font.pointSize: 15
            text: qsTr("手机号码：%1").arg(person.phone1)
        }
    }

    MouseArea {
        id: m_mouse
        anchors.fill: parent
        onClicked: clickSignal()
    }

    SplitLine {
        visible: index>0
        width: parent.width
        color: "#e1e1e1"
        anchors.top: parent.top
    }


    states: [
        State {
            when: m_mouse.pressed
            PropertyChanges { target: id_root; color: "#aaaaaa" }
        }
    ]

    function setText()
    {
        if(person.nickName === ""){
            if(person.name === ""){
                return person.phone1
            }else{
                return person.name
            }
        }else{
            return person.nickName
        }
    }
}

